import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class ExcelReader {
	public static List ReadItemRules(String filePath) {
		List list = new LinkedList();
		InputStream myxls = null;
		try {
			myxls = new FileInputStream(filePath);
			HSSFWorkbook wb = new HSSFWorkbook(myxls);
			myxls = new FileInputStream(new File(filePath));
			HSSFSheet sheet = wb.getSheetAt(3);
			for (int i = 3; i < sheet.getLastRowNum(); i++) {
				HSSFRow row = sheet.getRow(i);
				if (row == null) {
					continue;
				}
				ItemRules itemRules = new ItemRules(row);
				list.add(itemRules);
			}
			return list;
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				myxls.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return list;
	}

	public void contentReading(HSSFWorkbook wb) throws IOException {
		HSSFSheet sheet = wb.getSheetAt(3);
		for (int i = 3; i < sheet.getLastRowNum(); i++) {
			HSSFRow row = sheet.getRow(i);
			if (row == null) {
				continue;
			}
			ItemRules itemRules = new ItemRules(row);
			System.out.print(itemRules + "\n");
		}
	}
}
